﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CNRegex.Biz.BizAccess;
using CNRegex.Web.Base;
using CNRegex.Entity;
using CNRegex.Biz;

namespace CNRegex.Web.Controllers
{
	public class AdminRegexTutorialController : BaseController
	{
		private BizRegexTutorial bizRegexTutorial;
		public AdminRegexTutorialController()
		{
			bizRegexTutorial = BizFactory.Get<BizRegexTutorial>();
		}
		//
		// GET: /AdminRegexTutorial/
		public ActionResult Index()
		{
			return View(bizRegexTutorial.List(x => x.CreateDate, Enum.EnumOrder.DESC));
		}

		[HttpPost]
		public ActionResult Save(RegexTutorial model)
		{
			model.CreateDate = DateTime.Now;
			bizRegexTutorial.SaveOrUpdate(model);
			return RedirectToAction("Index");
		}
		[HttpPost]
		public ActionResult Delete(Guid id)
		{
			bizRegexTutorial.DeleteByID(id,NHibernate.NHibernateUtil.Guid);
			return Content("");
		}


	}
}
